package com.mmm.station.controller;


import com.mmm.station.entity.User;
import com.mmm.station.service.Server4Service;
import com.mmm.station.service.UserService;

import com.mmm.station.security.annotation.Power;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {


    @Autowired
    private Server4Service server4Service;

    @Autowired
    private UserService userService;


    @RequestMapping(value = "/getServer4", method = RequestMethod.GET)
    public String getServer4() {
        return server4Service.add();
    }


    @RequestMapping(value = "/add3", method = RequestMethod.GET)
    public Object add3() {
        return "你好  我是server3";
    }

    @Power(needRole = "aa")
    @RequestMapping(value = "/getList", method = RequestMethod.GET)
    public Object getList() {

        long startTime = System.nanoTime();
        List<User> users = userService.SelectList();
        System.out.print("执行时间为： +");
        System.out.println(System.nanoTime()-startTime);
        return users;
    }


    @RequestMapping(value = "/insertUser", method = RequestMethod.GET)
    public Object insertUser() {
        userService.insertUser();
        return "成功";
    }

}